<template>
  <div />
</template>
<script>
import * as echarts from "echarts";
/**
 * 图表业务组件
 * @module echartsTemplate
 *
 */
export default {
  name: "echartsTemplate",
  props: {
    chart: {
      type: Object,
    },
  },
  watch: {
    chart(val) {
      if (val) {
        this.setChart();
      }
    },
  },
  methods: {
    setChart() {
      const self = this;
      try {
        this.$emit("initCallback", self.$parent.option,this.chart);
        setTimeout(() => {
          this.chart.setOption(self.$parent.option);
          this.$emit("setUpdate", this.chart);
        }, 2000);
      } catch (err) {
        console.log(err)
        this.$emit("errCallback", err, this.chart);
      }
    },
  },
};
</script>
